﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Model;
using MB.Orm.DB;
using Public.DataAccess;
using MB.RuleBase.Common;
using Microsoft.Practices.EnterpriseLibrary.Data;

namespace Business
{
    public class BVenderGoodsLicense
    {
        public List<VenderUser_License> CheckVenderUserLicense(int VENDERID)
        {
            using (var DbScope = new OperationDatabaseScope(new OperationDatabaseContext("NewWeb")))
            {
                List<VenderUser_License> lstVenderUser_License = DatabaseExcuteByXmlHelper.NewInstance.GetObjectsByXml<VenderUser_License>("VenderUserLicense", "CheckVenderUserLicense", VENDERID);
                return lstVenderUser_License;
            }
        }

        //查询商品证书列表
        public List<VenderGoodsLicense> GetVenderGoodsLicenseList(int pageIndex, int pageSize, out int total, params object[] parValues)
        {
            using (var DbScope = new OperationDatabaseScope(new OperationDatabaseContext("NewWeb")))
            {
                List<VenderGoodsLicense> list = PagedDatabaseExcuteByXmlHelper.NewInstance.GetPagedObjectsByXml3<VenderGoodsLicense>
                                                ("VenderGoodsLicense", "GetVenderGoodsLicenseList", pageIndex, pageSize, out total, parValues);
                return list;
            }
        }

        /// <summary>
        /// 商品证书维护
        /// </summary>
        /// <param name="user"></param>
        /// <returns></returns>
        public int InsertVenderGoodsLicense(VenderGoodsLicense _VenderGoodsLicense)
        {
            using (var DbScope = new OperationDatabaseScope(new OperationDatabaseContext("NewWeb")))
            {
                return DatabaseExcuteByXmlHelper.NewInstance.ExecuteNonQueryByEntity<VenderGoodsLicense>
                                ("VenderGoodsLicense", "InsertVenderGoodsLicense", _VenderGoodsLicense);
            }
        }

        /// <summary>
        /// 删除用户
        /// </summary>
        /// <param name="code"></param>
        /// <returns></returns>
        public int DeleteVenderGoodsLicense(string code)
        {
            using (var DbScope = new OperationDatabaseScope(new OperationDatabaseContext("NewWeb")))
            {
                return DatabaseExcuteByXmlHelper.NewInstance.ExecuteNonQuery("VenderGoodsLicense", "DeleteVenderGoodsLicense", code);
            }
        }
    }
}
